﻿using AjaxPro;
using BLL.Access;
using System;
using System.Web;
namespace Web.ashx
{
    /// <summary>
    /// QS_YH 的摘要说明
    /// </summary>
    public class QS_YH : IHttpHandler
    {
        #region 变量
        SpHelper sphelper = new SpHelper();
        #endregion

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string methodName = context.Request["MethodName"];//接收方法名参数
            if (!string.IsNullOrEmpty(methodName))
            {
                System.Reflection.MethodInfo Method = this.GetType().GetMethod(methodName, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);//通过反射机制,直接对应到相应的方法
                if (Method != null)
                {
                    Method.Invoke(this, new object[] { context });
                }
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        } 
        #region ajax交互方法
         void GetInfo(HttpContext context)
        {
            string no = context.Request["No"];//接收参数
            string message;//返回信息;1.'该井编号存在！';2. '该井编号已经被注销！';3.'该井编号不存在！';
            string oldNo;//旧井编号
            string wellType;//井类型
            string isSuccess;//是否合法井
            sphelper.P_QSYH_CHECKJINGNO(no,out message,out oldNo,out wellType,out isSuccess);
            QS_NO qs_No = new QS_NO();
            qs_No.OldNo = oldNo;
            qs_No.Is_Success = isSuccess;
            qs_No.Message = message;
            qs_No.WellType = wellType;
            context.Response.Write(ToJson(qs_No));
            context.Response.End();
        }
        #endregion
        #region 实体对象转Json字符串方法
        public static string ToJson(object obj)
        {
            return JavaScriptSerializer.Serialize(obj);
        }
        #endregion
    }
    #region Json对象类
    
    /// <summary>
    /// 深井类型修改处理类
    /// </summary>
    [Serializable]
    public class QS_NO
    {
        /// <summary>
        /// 原井号
        /// </summary>
        public string OldNo { get; set; }
        /// <summary>
        /// 井类型
        /// </summary>
        public string WellType { get; set; }
        /// <summary>
        /// 是否成功（0失败,1成功）
        /// </summary>
        public string Is_Success { get; set; }
        /// <summary>
        /// 出错信息
        /// </summary>
        public string Message { get; set; }
    
    }
    #endregion



}